<?php

namespace App\Controllers;

use App\Controllers\BaseController;
use Illuminate\Http\Request;
use App\Services\RoleService;
use Illuminate\Support\Facades\Log;

/**
 * 角色管理类
 */
class RoleController extends BaseController
{
    public function roleAuthList(Request $request)
    {
        $params = $this->validate($request, [
                'role' => 'integer',
        ]);
        $data = RoleService::roleAuthList($params);
        return $data;
    }
    public function roleList(Request $request)
    {
        $page = $request->input('page', 1);
        $pageSize = $request->input('page_size', 20);
        return RoleService::roleList($page,$pageSize);
    }
    public  function editRoleAuth(Request $request)
    {
        $params = $this->validate($request, [
            'id'=>'integer',
            'role'=>'required|max:15',
            'auth'=>'required',
        ]);
        return RoleService::editRoleAuth($params);
    }
    public function delRole(Request $request){
        $params = $this->validate($request, [
            'id'=>'required|integer',
        ]);
        return RoleService::delRole($params);
    }
}
